package com.example.jmeter.enums;

import com.example.jmeter.util.FileUtil;
import com.example.jmeter.util.ZipUtil;

/**
 * @program: spring-agent
 * @description:
 * @author: zt22328
 * @create: 2023-04-18 17:28
 **/
public enum CompressType {

    // https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.5.zip
    ZIP(".zip") {
        @Override
        public void decompression(String source, String target, String reName) {
            ZipUtil.unZip(source, target, reName);
        }
    },

    GZ(".gz") {
        @Override
        public void decompression(String source, String target, String reName) {

        }
    },
    ;

    private String suffix;

    CompressType(String suffix) {
        this.suffix = suffix;
    }

    public static CompressType getCompressType(String suffix){
        for (CompressType value : CompressType.values()) {
            if (value.suffix.equals(suffix)) {
                return value;
            }
        }
        return null;
    }

    public abstract void decompression(String source, String target, String reName);

}
